﻿#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(LeanPool))]
public class LeanPool_Editor : Editor
{
    [MenuItem("GameObject/LeanPool/GameObjectPool", false, 1)]
    public static void CreateLocalization()
    {
        var gameObject = new GameObject(typeof(LeanPool).Name);

        Undo.RegisterCreatedObjectUndo(gameObject, "Create Pool");

        gameObject.AddComponent<LeanGameObjectPool>();

        Selection.activeGameObject = gameObject;
    }

    // Draw the whole inspector
    public override void OnInspectorGUI()
    {
        var pool = (LeanGameObjectPool)target;

        EditorGUI.BeginChangeCheck();
        {
            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("Prefab"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("Preload"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("Capacity"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("Notification"));

            EditorGUILayout.Separator();

            EditorGUI.EndDisabledGroup();
        }
        if (EditorGUI.EndChangeCheck()) EditorUtility.SetDirty(target);

        serializedObject.ApplyModifiedProperties();
    }
}

#endif